<?php
// Output html for archive page
function VNWP_output_html_posts($flagshare){
	
	        	if(have_posts()){
		        	while(have_posts()) : the_post();
		        	global $authordata;
		        	echo '<div class="blog-post">' ;
		        	echo '<a class="thumbnail left" href="'.get_permalink().'">';
		        	if (has_post_thumbnail()) {
						$thumb = wp_get_attachment_image_src(
									get_post_thumbnail_id(), 'full');	
		        		echo get_timthumb_img_src($thumb[0], 150, 150,
									get_the_title(), 'img-shadow');
						}
	        		else {
							echo get_img_src('thumbnail-default.png',get_the_title(), 'img-shadow');
					}	
		        	echo '</a>';
		        	echo '<p class="meta-data"><span class="comment-meta-post">By <a href="'.get_author_posts_url( $authordata->ID, $authordata->user_nicename ).'">'.get_the_author().'</a></span>';
		        	echo '<span class=""> On '.get_the_time('F j,Y').'</span>';
		        	// get comments
		        	$num_comments = get_comments_number(); // for some reason get_comments_number only returns a numeric value displaying the number of comments
					if ( comments_open() ){
					 	  if($num_comments == 0){
					 	  	  $comments = __(' Comment');
					 	  }
					 	  elseif($num_comments > 1){
					 	  	  $comments = __(' Comments');
					 	  }
					 	  else{
					 	  	   $comments =" Comment";
					 	  }
					 	$write_comments = '<span class="comment-meta-post right"><a href="'.get_comments_link().'">'.$num_comments.$comments.'</a></span>';
					 }
					else{$write_comments =  __('<span class="comment-meta-post right">Comments are off for this post</span>');}
					echo $write_comments;
		        	//echo '<span class="comment-meta right">'.get_comments_number().' Comments </span>';
		        	echo '</p>';
		        	//echo '<h1>'.get_the_title().'</h1>';
		        	echo '<p class="title"><a href="'.get_permalink().'">'.get_the_title().'</a></p>';
		        		 the_excerpt();
	        		if ($flagshare)
	        		{
		        		 if(function_exists('st_makeEntries')){
						echo '<p class="share-this">';
						echo st_makeEntries();
						echo '</p><!--#share-this-->';
						}
	        		}
		        	echo '<a class="readmore-link" href="'.get_permalink().'">Read more</a>';
		        	echo '</div><!--End .blog-post-->';
		        	endwhile;
	        	}				
}

// override category title
function childtheme_override_page_title()
{
	
}
// override the category loop
function childtheme_override_category_loop()
{
	$flagshare = true;
	VNWP_output_html_posts($flagshare);
  				
}
function childtheme_override_author_loop()
{
	$flagshare = true;
	VNWP_output_html_posts($flagshare);
  				
}
function childtheme_override_search_loop()
{
			$flagshare = true;
			global $post;
			if(have_posts()){
		        	while(have_posts()) : the_post();
		        	
		        	global $authordata;
		        	if ($post->post_type == 'page')
		        	 		continue;
		        	echo '<div class="blog-post">' ;
		        	echo '<a class="thumbnail left" href="'.get_permalink().'">';
		        	if (has_post_thumbnail()) {
						$thumb = wp_get_attachment_image_src(
									get_post_thumbnail_id(), 'full');	
		        		echo get_timthumb_img_src($thumb[0], 150, 150,
									get_the_title(), 'img-shadow');
						}
	        		else {
							echo get_img_src('thumbnail-default.png',get_the_title(), 'img-shadow');
					}	
		        	echo '</a>';
		        	echo '<p class="meta-data"><span class="comment-meta-post">By <a href="'.get_author_posts_url( $authordata->ID, $authordata->user_nicename ).'">'.get_the_author().'</a></span>';
		        	echo '<span class=""> On '.get_the_time('F j,Y').'</span>';
		        	// get comments
		        	$num_comments = get_comments_number(); // for some reason get_comments_number only returns a numeric value displaying the number of comments
					if ( comments_open() ){
					 	  if($num_comments == 0){
					 	  	  $comments = __(' Comment');
					 	  }
					 	  elseif($num_comments > 1){
					 	  	  $comments = __(' Comments');
					 	  }
					 	  else{
					 	  	   $comments =" Comment";
					 	  }
					 	$write_comments = '<span class="comment-meta-post right"><a href="'.get_comments_link().'">'.$num_comments.$comments.'</a></span>';
					 }
					else{$write_comments =  __('<span class="comment-meta-post right">Comments are off for this post</span>');}
					echo $write_comments;
		        	//echo '<span class="comment-meta right">'.get_comments_number().' Comments </span>';
		        	echo '</p>';
		        	//echo '<h1>'.get_the_title().'</h1>';
		        	echo '<p class="title"><a href="'.get_permalink().'">'.get_the_title().'</a></p>';
		        		 the_excerpt();
	        		if ($flagshare)
	        		{
		        		 if(function_exists('st_makeEntries')){
						echo '<p class="share-this">';
						echo st_makeEntries();
						echo '</p><!--#share-this-->';
						}
	        		}
		        	echo '<a class="readmore-link" href="'.get_permalink().'">Read more</a>';
		        	echo '</div><!--End .blog-post-->';
		        	endwhile;
	        	}
  				
}
function childtheme_override_tag_loop() {
	$flagshare = true;
	VNWP_output_html_posts($flagshare);
}
function childtheme_override_archive_loop(){
	$flagshare = true;
	VNWP_output_html_posts($flagshare);
}

?>